<template>
  <div id="app">
    <router-view v-if="path === '/'"></router-view>
    <CommonLayout v-if="path !== '/'"></CommonLayout>
  </div>
</template>
<script>
import CommonLayout from "@/layouts/default.vue";
import { mapGetters } from "vuex";
export default {
  computed: {
    ...mapGetters("user", ["isLogin", "userInfo"]),
    path() {
      return this.$route.path;
    }
  },
  created() {},
  mounted: function() {
    if (sessionStorage.getItem("token")) {
      var userInfo = {};
      var userInfoStr = sessionStorage.getItem("userInfo");
      if (userInfoStr) {
        userInfo = JSON.parse(userInfoStr);
      }

      this.$cloud
        .invokeMethod("User/Login", [userInfo.name.length, userInfo.name])
        .then(res => {
          console.log("User/Login res", res);
        })
        .catch(error => {
          console.log("User/Login error", error);
        });
    }
  },
  components: {
    CommonLayout
  }
};
</script>

<style lang="less">
#app {
  height: 100%;
}
.ant-menu-item .anticon,
.ant-menu-submenu-title .anticon {
  font-size: 16px;
}
</style>
